<?php

namespace App\Admin\Actions\Admin;

use App\Models\AgentInfo;
use Encore\Admin\Actions\Action;
use Encore\Admin\Actions\RowAction;
use Illuminate\Http\Request;

class AgentQywx extends RowAction
{
    protected $selector = '.agent-qywx';

    public $name = '绑定企业微信';


    public function handle(AgentInfo $agentInfo,Request $request)
    {
        $agentInfo->qywx = $request->qywx;
        $agentInfo->save();

        return $this->response()->success('企业微信修改成功')->refresh();
    }

    public function html()
    {
        return <<<HTML
        <a class="btn btn-sm btn-default agent-qywx"></a>
HTML;
    }

    public function form(AgentInfo $agentInfo)
    {
        $this->text('qywx', '企业微信')->default($agentInfo->qywx);
    }
}
